package org.chen.common.flight.response;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.chen.common.flight.RoundTripFlightInfo;
import org.chen.common.flight.request.FlightSearchRequest;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

// ==================== 4. 往返搜索响应 ====================
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class RoundTripFlightSearchResponse {
    private boolean success;
    private String message;
    private String transactionId;
    private LocalDateTime timestamp;
    private FlightSearchRequest searchRequest;
    
    private List<RoundTripFlightInfo> flights;
    private int totalCount;
    private Map<String, Object> metadata;
    
    public static RoundTripFlightSearchResponse success() {
        RoundTripFlightSearchResponse response = new RoundTripFlightSearchResponse();
        response.setSuccess(true);
        response.setTimestamp(LocalDateTime.now());
        response.setFlights(new ArrayList<>());
        response.setMetadata(new HashMap<>());
        return response;
    }
    
    public static RoundTripFlightSearchResponse error(String message) {
        RoundTripFlightSearchResponse response = new RoundTripFlightSearchResponse();
        response.setSuccess(false);
        response.setMessage(message);
        response.setTimestamp(LocalDateTime.now());
        return response;
    }
}